using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Labirinto_Magico
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        RenderingData renderingData;
        SoundHandler soundHandler;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);

            soundHandler = new SoundHandler();
            this.Services.AddService(typeof(SoundHandler), soundHandler);

            Content.RootDirectory = "Content";

            renderingData = new RenderingData();
            this.Services.AddService(typeof(RenderingData), renderingData);

            Components.Add(new MainMenu(this));

            this.graphics.PreferredBackBufferWidth = 1280;
            this.graphics.PreferredBackBufferHeight = 800;
            //graphics.IsFullScreen = true;
            IsMouseVisible = true;
        }

        protected override void Initialize()
        {
            soundHandler.Init(Content);
            renderingData.Load(GraphicsDevice, Content);
            base.Initialize();
        }

        protected override void LoadContent()
        {
            renderingData.Load(GraphicsDevice, this.Content);
            soundHandler.Init(Content);
        }

        protected override void UnloadContent()
        { }

        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();
            InputHandlerModule.inputHandler.Update(gameTime);
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            renderingData.DrawBackground();
            base.Draw(gameTime);
        }        
    }
}
